<template>
  <nav-bar class="detail-nav">
    <div slot="left"
          class="back"
          @click="backClick">
      <img src="~assets/img/common/back.svg"
            alt="">
    </div>
    <div slot="center"
          class="title">
      <div v-for="(item, index) in titles"
            :key="index"
            class="title-item"
            :class="{active: index === currentIndex}"
            @click="titleClick(index)">
        {{item}}
      </div>
    </div>
  </nav-bar>
</template>

<script>
  import NavBar from 'components/common/navbar/NavBar'

  export default {
    name: "DetailNavBar",
    components: {
      NavBar
    },
    data () {
      return {
        // currentIndex: this.current
      }
    },
    props: {
		  titles: {
		    type: Array,
        default: () => {
          return ['商品', '参数', '评论', '推荐']
        }
      },
      currentIndex: {
		    type: Number,
        default: 0
      }
    },
    methods: {
      /**
       * 点击事件
       */
      titleClick(index) {
        this.$emit('navClick', index)
      },
      backClick() {
        this.$router.back()
      }
    }
  }
</script>

<style scoped>
  .detail-nav {
      background-color: #fff;
      font-weight: normal;
    }

  .title {
    display: flex;
    text-align: center;
    font-size: 13px;

    z-index: 9;
  }

  .title-item {
    flex: 1;
  }

  .title .active {
    color: var(--color-high-text);
    /* border-bottom: 1px solid var(--color-high-text); */
  }

  .back img {
    margin-top: 12px;
  }
</style>
